#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

vector<int> bubbleSort(vector<int> arr) {
  int round = 0;

  while (round != arr.size() - 1) {
    for  (int i = arr.size() - 1; i > round; --i)
    {
      if (arr[i - 1] > arr[i]){
        swap(arr[i-1], arr[i]);
      }

    }
    
    ++round;
  }
  return arr;
}

int main(int argc, char const *argv[])
{
  vector<int> v {1, 4, 3, 6, 8, 7, 2, 5, 9};
  auto sorted = bubbleSort(v);

  for (auto n : sorted) {
    cout<<n<<" ";
  }

  cout<<endl;
  return 0;
}
